namespace Vanilla.UI

import System
import System.Runtime.InteropServices

// PATTERN
abstract class Pattern (IDisposable):
	public Handle as IntPtr
	Disposed = false
	
	protected def constructor (h as IntPtr):
		Handle = h
	
	def Dispose ():
		Disposed = true
		Cairo.PatternDestroy(Handle)
	
	def destructor ():
		Dispose() unless Disposed

// GRADIENT
abstract class Gradient (Pattern):
	protected def constructor (h as IntPtr):
		super(h)
	
	def Add (pos as double, c as Colour):
		Cairo.PatternAddColorStopRGBA(Handle, pos, c.R, c.G, c.B, c.A)

class LinearGradient (Gradient):
	def constructor (x as double, y as double, x2 as double, y2 as double):
		super(Cairo.PatternCreateLinear(x,y,x2,y2))

// CANVAS PATTERN
class CanvasPattern (Pattern):
	def constructor (c as Canvas):
		super(Cairo.PatternCreateForSurface(c.Handle))
